using collision_and_rigid;
using game_config;

namespace game_stuff
{
    public class RangeAttackStatus
    {
        private float NearDamageAdd;
        private float FarDamageAdd;
        public float FullAmmoCostRate;
        public float FullDamageAdd;
        public bool FullAmmoDamageActive;

        public RangeAttackStatus()
        {
            NearDamageAdd = 0;
            FarDamageAdd = 0;
            FullAmmoCostRate = 0;
            FullDamageAdd = 0;
            FullAmmoDamageActive = false;
        }

        public void Refresh(float[] vector)
        {
            NearDamageAdd = vector[0];
            FarDamageAdd = vector[1];
            FullAmmoCostRate = vector[2];
            FullDamageAdd = vector[3];
        }

        public float GenRangeDmgMulti(CharacterBody characterBody, IBattleUnitStatus target)
        {
            var twoDPoint = characterBody.GetAnchor();
            var dPoint = target.GetPos();
            var rangeAddMaxValue = CommonConfig.OtherConfig!.range_add_max_value;
            var distance = MathTools.Min(rangeAddMaxValue, twoDPoint.GetDistance(dPoint));
            var rangeAddChangeValue = CommonConfig.OtherConfig.range_add_change_value;


            var addChangeValue = distance - rangeAddChangeValue;
            var a = MathTools.Max(0, addChangeValue * FarDamageAdd);
            var b = MathTools.Max(0, -addChangeValue * NearDamageAdd);
            return a + b;
        }
    }
}